import { IsString, IsNumber, IsOptional, Min, Max } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';

export class ListModelsQueryDto {
  @ApiPropertyOptional({ 
    description: 'Number of models to return', 
    minimum: 1, 
    maximum: 1000, 
    default: 20 
  })
  @IsOptional()
  @IsNumber()
  @Min(1)
  @Max(1000)
  @Transform(({ value }) => parseInt(value))
  limit?: number = 20;

  @ApiPropertyOptional({ 
    description: 'Cursor for pagination - return results before this ID' 
  })
  @IsOptional()
  @IsString()
  before_id?: string;

  @ApiPropertyOptional({ 
    description: 'Cursor for pagination - return results after this ID' 
  })
  @IsOptional()
  @IsString()
  after_id?: string;
}

export class ModelDto {
  @ApiProperty({ description: 'Model identifier', example: 'claude-sonnet-4-20250514' })
  id: string;

  @ApiProperty({ enum: ['model'], description: 'Object type' })
  type: 'model';

  @ApiProperty({ description: 'Human-readable model name', example: 'Claude Sonnet 4' })
  display_name: string;

  @ApiProperty({ description: 'Model creation timestamp', example: '2025-05-14T00:00:00Z' })
  created_at: string;
}

export class ModelsResponseDto {
  @ApiProperty({ type: [ModelDto], description: 'Array of model objects' })
  data: ModelDto[];

  @ApiProperty({ 
    description: 'ID of the first model in the list', 
    nullable: true,
    example: 'claude-sonnet-4-20250514'
  })
  first_id: string | null;

  @ApiProperty({ 
    description: 'ID of the last model in the list', 
    nullable: true,
    example: 'claude-opus-4-20250514'
  })
  last_id: string | null;

  @ApiProperty({ description: 'Whether there are more models available' })
  has_more: boolean;
}

export class GetModelParamsDto {
  @ApiProperty({ description: 'Model identifier or alias' })
  @IsString()
  model_id: string;
}